/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2024-11-23
 * Time: 12:11
 */
class Solution1 {
    public int hammingWeight(int n) {
        int count = 0;
        while(n != 0){
            n &= (n-1);  //干掉n最右侧的1
            count++;
        }
        return count;
    }
}
public class Test1 {
}
